﻿using System;
using System.Data;
using UniMana.Utils.Data;
using UniMana.Data;

namespace UniMana.Win.Training
{
    public class Cls_ConvertDataToSchedule
    {
        DataTable m_tblTable;
        DataTable m_tblWeek1;
        DataTable m_tblWeek2;
        int pointEnd = -12; // Vị trí ngày kết thúc tuần
        DataTable m_tblTableAllData;
        DataTable m_tblScheduleAll;
        DataTable m_tblScheduleWeek;
        DBMain m_data = new DBMain();
        string[,] m_aSchedule;
        int r = 16;
        int c = 9;

        public DataTable Implementation(DataTable m_tblTableAll)
        {
            DataTable m_tblTableAllData = new DataTable();
            this.m_tblTableAllData = m_tblTableAll;
            ResetValues();
            //m_tblScheduleAll = ReInitalScheduleTable(m_tblScheduleAll);
            GetDataForWeek();
            return m_tblScheduleAll;
        }

        /// <summary>
        /// Khởi tạo lại giá trị
        /// </summary>

        private void ResetValues()
        {
            pointEnd = -12;
            // table chua du lieu 1 tuan
            m_tblWeek2 = InitalDataTableWeek(m_tblWeek2);
            // table chua du lieu sau khi chinh sua
            m_tblScheduleWeek = InitalScheduleTable(m_tblScheduleWeek);
            m_tblWeek1 = InitalDataTableWeek(m_tblWeek1);
            m_tblScheduleAll = InitalScheduleTable(m_tblScheduleAll);
        }

        /// <summary>
        /// Lấy thông tin giảng viên từng tuần
        /// </summary>

        private void GetDataForWeek()
        {
            DateTime start = new DateTime();
            DateTime end = new DateTime();
            m_tblWeek1 = ReInitalDataTableWeek(m_tblWeek1);

        aaa:
            DateTime _datetime = new DateTime();
            _datetime = (DateTime)(m_tblTableAllData.Rows[0]["RegistTime"]);
            m_tblWeek2 = ReInitalDataTableWeek(m_tblWeek2);
            int _i = 0;
            while (m_tblTableAllData.Rows.Count != 0)
            {
                //if (_i < int.Parse(m_tblTableAllData.Rows[0]["Training_WeekDayKey"].ToString()))
                if ((_i < int.Parse(m_tblTableAllData.Rows[0]["Training_WeekDayKey"].ToString())) || ((_i == int.Parse(m_tblTableAllData.Rows[0]["Training_WeekDayKey"].ToString())) && (_datetime == (DateTime)(m_tblTableAllData.Rows[0]["RegistTime"]))))
                {
                    _i = int.Parse(m_tblTableAllData.Rows[0]["Training_WeekDayKey"].ToString());
                    m_tblWeek2.Rows.Add(m_tblTableAllData.Rows[0]["Training_SessionKey"], m_tblTableAllData.Rows[0]["SessionName"], m_tblTableAllData.Rows[0]["SessionStartTime"], m_tblTableAllData.Rows[0]["SessionFinishTime"], m_tblTableAllData.Rows[0]["Training_Subject_ClassKey"], m_tblTableAllData.Rows[0]["ClassID"], m_tblTableAllData.Rows[0]["ClassName"], m_tblTableAllData.Rows[0]["Training_SubjectKey"], m_tblTableAllData.Rows[0]["SubjectID"], m_tblTableAllData.Rows[0]["SubjectName"], m_tblTableAllData.Rows[0]["Credit"], m_tblTableAllData.Rows[0]["Training_Class_RoomKey"], m_tblTableAllData.Rows[0]["RoomID"], m_tblTableAllData.Rows[0]["RoomName"], m_tblTableAllData.Rows[0]["Catalogue_TermKey"], m_tblTableAllData.Rows[0]["Catalogue_SchoolYearKey"], m_tblTableAllData.Rows[0]["Personnel_PersonnelKey"], m_tblTableAllData.Rows[0]["PersonID"], m_tblTableAllData.Rows[0]["PersonLastName"], m_tblTableAllData.Rows[0]["PersonName"], m_tblTableAllData.Rows[0]["RegistTime"], m_tblTableAllData.Rows[0]["Training_WeekDayKey"], m_tblTableAllData.Rows[0]["WeekDayName"]);
                    m_tblTableAllData.Rows.RemoveAt(0);
                }
                else
                    break;
            }

            // Nhóm dữ liệu 2 tuần lại nếu trùng
            if (GroupScheduleWeek(ref m_tblWeek1, ref m_tblWeek2, ref pointEnd, ref end))
                goto bbb;

            // Duyệt và xử lý dữ liệu từng tuần
            start = Convert.ToDateTime(m_tblWeek2.Rows[0]["RegistTime"].ToString());
            end = Convert.ToDateTime(m_tblWeek2.Rows[m_tblWeek2.Rows.Count - 1]["RegistTime"].ToString());
            pointEnd = pointEnd + 16;
            InitalArray(start, end);
            ConvertDataToSchedule();
            if (m_tblWeek2.Rows.Count != 0)
            {
                for (int i = 0; i < r; i++)
                    m_tblScheduleAll.Rows.Add(m_aSchedule[i, 0], m_aSchedule[i, 1], m_aSchedule[i, 2], m_aSchedule[i, 3], m_aSchedule[i, 4], m_aSchedule[i, 5], m_aSchedule[i, 6], m_aSchedule[i, 7], m_aSchedule[i, 8]);
            }

        bbb:
            if (m_tblTableAllData.Rows.Count != 0)
                goto aaa;
        }

        /// <summary>
        /// Nhóm dữ liệu 2 tuần lại nếu trùng
        /// </summary>
        /// <param name="week1"></param>
        /// <param name="week2"></param>
        /// <param name="point2"></param>
        /// <param name="end"></param>
        /// <returns></returns>

        private bool GroupScheduleWeek(ref DataTable week1, ref DataTable week2, ref int point2, ref DateTime end)
        {
            if (m_tblWeek1.Rows.Count != m_tblWeek2.Rows.Count)
            {
                ConvertTable(ref m_tblWeek1, m_tblWeek2);
                return false;
            }
            if (m_tblWeek1.Rows.Count == m_tblWeek2.Rows.Count)
            {
                for (int i = 0; i < m_tblWeek2.Rows.Count; i++)
                {
                    if ((m_tblWeek1.Rows[i]["Training_SessionKey"].ToString() != m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) || (m_tblWeek1.Rows[i]["Training_Subject_ClassKey"].ToString() != m_tblWeek2.Rows[i]["Training_Subject_ClassKey"].ToString()) || (m_tblWeek1.Rows[i]["Training_SubjectKey"].ToString() != m_tblWeek2.Rows[i]["Training_SubjectKey"].ToString()) || (m_tblWeek1.Rows[i]["Credit"].ToString() != m_tblWeek2.Rows[i]["Credit"].ToString()) || (m_tblWeek1.Rows[i]["Training_Class_RoomKey"].ToString() != m_tblWeek2.Rows[i]["Training_Class_RoomKey"].ToString()) || (m_tblWeek1.Rows[i]["Catalogue_TermKey"].ToString() != m_tblWeek2.Rows[i]["Catalogue_TermKey"].ToString()) || (m_tblWeek1.Rows[i]["Catalogue_SchoolYearKey"].ToString() != m_tblWeek2.Rows[i]["Catalogue_SchoolYearKey"].ToString()) || (m_tblWeek1.Rows[i]["Training_WeekDayKey"].ToString() != m_tblWeek2.Rows[i]["Training_WeekDayKey"].ToString()))
                    {
                        ConvertTable(ref m_tblWeek1, m_tblWeek2);
                        return false;
                    }
                }
            }
            if (week2.Rows.Count != 0)
            {
                m_tblScheduleAll.Rows[pointEnd][0] = Convert.ToDateTime(m_tblWeek2.Rows[m_tblWeek2.Rows.Count - 1]["RegistTime"].ToString()).Date.Day.ToString() + "-" + Convert.ToDateTime(m_tblWeek2.Rows[m_tblWeek2.Rows.Count - 1]["RegistTime"].ToString()).Date.Month.ToString() + "-" + Convert.ToDateTime(m_tblWeek2.Rows[m_tblWeek2.Rows.Count - 1]["RegistTime"].ToString()).Date.Year.ToString();
                ConvertTable(ref m_tblWeek1, m_tblWeek2);
                return true;
            }
            return false;
        }

        /// <summary>
        /// Chuyển dữ liệu từ table A sang B
        /// </summary>
        /// <param name="week1"></param>
        /// <param name="week2"></param>

        private void ConvertTable(ref DataTable week1, DataTable week2)
        {
            week1 = ReInitalDataTableWeek(week1);
            for (int i = 0; i < week2.Rows.Count; i++)
                week1.Rows.Add(week2.Rows[i][0], week2.Rows[i][1], week2.Rows[i][2], week2.Rows[i][3], week2.Rows[i][4], week2.Rows[i][5], week2.Rows[i][6], week2.Rows[i][7], week2.Rows[i][8], week2.Rows[i][9], week2.Rows[i][10], week2.Rows[i][11], week2.Rows[i][12], week2.Rows[i][13], week2.Rows[i][14], week2.Rows[i][15], week2.Rows[i][16], week2.Rows[i][17], week2.Rows[i][18], week2.Rows[i][19], week2.Rows[i][20], week2.Rows[i][21], week2.Rows[i][22]);
        }

        /// <summary>
        /// Khởi tạo mảng chứa dữ liệu
        /// </summary>
        /// <param name="m_dStart"></param>
        /// <param name="m_dEnd"></param>

        private void InitalArray(DateTime m_dStart, DateTime m_dEnd)
        {
            m_aSchedule = new string[r, c];
            for (int i = 0; i < r; i++)
            {
                for (int j = 0; j < c; j++)
                    m_aSchedule[i, j] = "";
            }
            m_tblTable = (this.m_data.m_DCReadOnly.Training_Sessions.GetDataKeyNameStarFinishTime()).ToDataTable();
            m_aSchedule[0, 0] = "Ngày";
            m_aSchedule[0, 1] = "Buổi";
            m_aSchedule[0, 2] = "Thứ 2";
            m_aSchedule[0, 3] = "Thứ 3";
            m_aSchedule[0, 4] = "Thứ 4";
            m_aSchedule[0, 5] = "Thứ 5";
            m_aSchedule[0, 6] = "Thứ 6";
            m_aSchedule[0, 7] = "Thứ 7";
            m_aSchedule[0, 8] = "Chủ nhật";
            m_aSchedule[1, 0] = "Từ ngày";
            m_aSchedule[2, 0] = m_dStart.Date.Day.ToString() + "-" + m_dStart.Date.Month.ToString() + "-" + m_dStart.Date.Year.ToString();
            m_aSchedule[3, 0] = "Đến ngày";
            m_aSchedule[4, 0] = m_dEnd.Date.Day.ToString() + "-" + m_dEnd.Date.Month.ToString() + "-" + m_dEnd.Date.Year.ToString();
            m_aSchedule[1, 1] = "Ca 1";
            m_aSchedule[2, 1] = m_tblTable.Rows[0]["StartTime"].ToString().Substring(0, 5);
            m_aSchedule[3, 1] = m_tblTable.Rows[0]["FinishTime"].ToString().Substring(0, 5);
            m_aSchedule[6, 1] = "Ca 2";
            m_aSchedule[7, 1] = m_tblTable.Rows[1]["StartTime"].ToString().Substring(0, 5);
            m_aSchedule[8, 1] = m_tblTable.Rows[1]["FinishTime"].ToString().Substring(0, 5);
            m_aSchedule[11, 1] = "Ca 3";
            m_aSchedule[12, 1] = m_tblTable.Rows[2]["StartTime"].ToString().Substring(0, 5);
            m_aSchedule[13, 1] = m_tblTable.Rows[2]["FinishTime"].ToString().Substring(0, 5);
        }

        /// <summary>
        /// Khởi tạo lại table chứa lịch công tác từng tuần
        /// </summary>
        /// <param name="m_tbl"></param>
        /// <returns></returns>

        private DataTable ReInitalScheduleTable(DataTable m_tbl)
        {
            m_tbl.Columns.Clear();
            m_tbl.Rows.Clear();
            m_tbl = InitalScheduleTable(m_tbl);
            return m_tbl;
        }

        /// <summary>
        /// Khởi tạo table chứa lịch công tác từng tuần
        /// </summary>
        /// <param name="m_tbl"></param>
        /// <returns></returns>

        private DataTable InitalScheduleTable(DataTable m_tbl)
        {
            m_tbl = new DataTable();
            m_tbl.Columns.Add("Ngày");
            m_tbl.Columns.Add("Buổi");
            m_tbl.Columns.Add("Thứ 2");
            m_tbl.Columns.Add("Thứ 3");
            m_tbl.Columns.Add("Thứ 4");
            m_tbl.Columns.Add("Thứ 5");
            m_tbl.Columns.Add("Thứ 6");
            m_tbl.Columns.Add("Thứ 7");
            m_tbl.Columns.Add("Chủ nhật");
            return m_tbl;
        }

        /// <summary>
        /// Khởi tạo lại table chứa dữ liệu từng tuần
        /// </summary>
        /// <param name="m_tblWeek"></param>
        /// <returns></returns>

        private DataTable ReInitalDataTableWeek(DataTable m_tblWeek)
        {
            m_tblWeek.Columns.Clear();
            m_tblWeek.Rows.Clear();
            m_tblWeek = InitalDataTableWeek(m_tblWeek);
            return m_tblWeek;
        }

        /// <summary>
        /// Khởi tạo table chứa dữ liệu từng tuần
        /// </summary>
        /// <param name="m_tblWeek"></param>
        /// <returns></returns>

        private DataTable InitalDataTableWeek(DataTable m_tblWeek)
        {
            m_tblWeek = new DataTable();
            m_tblWeek.Columns.Add("Training_SessionKey");
            m_tblWeek.Columns.Add("SessionName");
            m_tblWeek.Columns.Add("SessionStartTime");
            m_tblWeek.Columns.Add("SessionFinishTime ");
            m_tblWeek.Columns.Add("Training_Subject_ClassKey");
            m_tblWeek.Columns.Add("ClassID");
            m_tblWeek.Columns.Add("ClassName");
            m_tblWeek.Columns.Add("Training_SubjectKey");
            m_tblWeek.Columns.Add("SubjectID");
            m_tblWeek.Columns.Add("SubjectName");
            m_tblWeek.Columns.Add("Credit");
            m_tblWeek.Columns.Add("Training_Class_RoomKey");
            m_tblWeek.Columns.Add("RoomID");
            m_tblWeek.Columns.Add("RoomName");
            m_tblWeek.Columns.Add("Catalogue_TermKey");
            m_tblWeek.Columns.Add("Catalogue_SchoolYearKey");
            m_tblWeek.Columns.Add("Personnel_PersonnelKey");
            m_tblWeek.Columns.Add("PersonID");
            m_tblWeek.Columns.Add("PersonLastName");
            m_tblWeek.Columns.Add("PersonName");
            m_tblWeek.Columns.Add("RegistTime");
            m_tblWeek.Columns.Add("Training_WeekDayKey");
            m_tblWeek.Columns.Add("WeekDayName");
            return m_tblWeek;
        }

        /// <summary>
        /// Chuyển dữ liệu lưu trữ sang lịch công tác
        /// </summary>

        private void ConvertDataToSchedule()
        {
            if (m_tblWeek2.Rows.Count != 0)
            {
                for (int i = 0; i < m_tblWeek2.Rows.Count; i++)
                {
                    if (int.Parse(m_tblWeek2.Rows[i]["Training_WeekDayKey"].ToString()) == 2)
                    {
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 1)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[1, 2].ToString() != "")
                                    m_aSchedule[1, 2] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[1, 2] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[2, 2].ToString() != "")
                                    m_aSchedule[2, 2] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[2, 2] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[3, 2].ToString() != "")
                                    m_aSchedule[3, 2] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[3, 2] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[4, 2].ToString() != "")
                                    m_aSchedule[4, 2] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[4, 2] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[5, 2].ToString() != "")
                                    m_aSchedule[5, 2] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[5, 2] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 2)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[6, 2].ToString() != "")
                                    m_aSchedule[6, 2] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[6, 2] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[7, 2].ToString() != "")
                                    m_aSchedule[7, 2] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[7, 2] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[8, 2].ToString() != "")
                                    m_aSchedule[8, 2] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[8, 2] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[9, 2].ToString() != "")
                                    m_aSchedule[9, 2] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[9, 2] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[10, 2].ToString() != "")
                                    m_aSchedule[10, 2] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[10, 2] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 3)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[11, 2].ToString() != "")
                                    m_aSchedule[11, 2] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[11, 2] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[12, 2].ToString() != "")
                                    m_aSchedule[12, 2] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[12, 2] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[13, 2].ToString() != "")
                                    m_aSchedule[13, 2] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[13, 2] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[14, 2].ToString() != "")
                                    m_aSchedule[14, 2] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[14, 2] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[15, 2].ToString() != "")
                                    m_aSchedule[15, 2] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[15, 2] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                    }
                    if (int.Parse(m_tblWeek2.Rows[i]["Training_WeekDayKey"].ToString()) == 3)
                    {
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 1)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[1, 3].ToString() != "")
                                    m_aSchedule[1, 3] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[1, 3] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[2, 3].ToString() != "")
                                    m_aSchedule[2, 3] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[2, 3] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[3, 3].ToString() != "")
                                    m_aSchedule[3, 3] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[3, 3] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[4, 3].ToString() != "")
                                    m_aSchedule[4, 3] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[4, 3] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[5, 3].ToString() != "")
                                    m_aSchedule[5, 3] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[5, 3] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 2)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[6, 3].ToString() != "")
                                    m_aSchedule[6, 3] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[6, 3] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[7, 3].ToString() != "")
                                    m_aSchedule[7, 3] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[7, 3] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[8, 3].ToString() != "")
                                    m_aSchedule[8, 3] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[8, 3] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[9, 3].ToString() != "")
                                    m_aSchedule[9, 3] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[9, 3] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[10, 3].ToString() != "")
                                    m_aSchedule[10, 3] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[10, 3] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 3)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[11, 3].ToString() != "")
                                    m_aSchedule[11, 3] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[11, 3] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[12, 3].ToString() != "")
                                    m_aSchedule[12, 3] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[12, 3] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[13, 3].ToString() != "")
                                    m_aSchedule[13, 3] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[13, 3] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[14, 3].ToString() != "")
                                    m_aSchedule[14, 3] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[14, 3] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[15, 3].ToString() != "")
                                    m_aSchedule[15, 3] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[15, 3] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                    }
                    if (int.Parse(m_tblWeek2.Rows[i]["Training_WeekDayKey"].ToString()) == 4)
                    {
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 1)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[1, 4].ToString() != "")
                                    m_aSchedule[1, 4] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[1, 4] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[2, 4].ToString() != "")
                                    m_aSchedule[2, 4] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[2, 4] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[3, 4].ToString() != "")
                                    m_aSchedule[3, 4] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[3, 4] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[4, 4].ToString() != "")
                                    m_aSchedule[4, 4] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[4, 4] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[5, 4].ToString() != "")
                                    m_aSchedule[5, 4] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[5, 4] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 2)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[6, 4].ToString() != "")
                                    m_aSchedule[6, 4] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[6, 4] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[7, 4].ToString() != "")
                                    m_aSchedule[7, 4] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[7, 4] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[8, 4].ToString() != "")
                                    m_aSchedule[8, 4] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[8, 4] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[9, 4].ToString() != "")
                                    m_aSchedule[9, 4] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[9, 4] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[10, 4].ToString() != "")
                                    m_aSchedule[10, 4] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[10, 4] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 3)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[11, 4].ToString() != "")
                                    m_aSchedule[11, 4] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[11, 4] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[12, 4].ToString() != "")
                                    m_aSchedule[12, 4] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[12, 4] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[13, 4].ToString() != "")
                                    m_aSchedule[13, 4] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[13, 4] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[14, 4].ToString() != "")
                                    m_aSchedule[14, 4] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[14, 4] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[15, 4].ToString() != "")
                                    m_aSchedule[15, 4] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[15, 4] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                    }
                    if (int.Parse(m_tblWeek2.Rows[i]["Training_WeekDayKey"].ToString()) == 5)
                    {
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 1)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[1, 5].ToString() != "")
                                    m_aSchedule[1, 5] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[1, 5] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[2, 5].ToString() != "")
                                    m_aSchedule[2, 5] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[2, 5] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[3, 5].ToString() != "")
                                    m_aSchedule[3, 5] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[3, 5] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[4, 5].ToString() != "")
                                    m_aSchedule[4, 5] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[4, 5] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[5, 5].ToString() != "")
                                    m_aSchedule[5, 5] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[5, 5] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 2)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[6, 5].ToString() != "")
                                    m_aSchedule[6, 5] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[6, 5] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[7, 5].ToString() != "")
                                    m_aSchedule[7, 5] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[7, 5] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[8, 5].ToString() != "")
                                    m_aSchedule[8, 5] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[8, 5] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[9, 5].ToString() != "")
                                    m_aSchedule[9, 5] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[9, 5] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[10, 5].ToString() != "")
                                    m_aSchedule[10, 5] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[10, 5] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 3)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[11, 5].ToString() != "")
                                    m_aSchedule[11, 5] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[11, 5] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[12, 5].ToString() != "")
                                    m_aSchedule[12, 5] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[12, 5] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[13, 5].ToString() != "")
                                    m_aSchedule[13, 5] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[13, 5] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[14, 5].ToString() != "")
                                    m_aSchedule[14, 5] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[14, 5] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[15, 5].ToString() != "")
                                    m_aSchedule[15, 5] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[15, 5] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                    }
                    if (int.Parse(m_tblWeek2.Rows[i]["Training_WeekDayKey"].ToString()) == 6)
                    {
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 1)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[1, 6].ToString() != "")
                                    m_aSchedule[1, 6] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[1, 6] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[2, 6].ToString() != "")
                                    m_aSchedule[2, 6] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[2, 6] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[3, 6].ToString() != "")
                                    m_aSchedule[3, 6] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[3, 6] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[4, 6].ToString() != "")
                                    m_aSchedule[4, 6] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[4, 6] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[5, 6].ToString() != "")
                                    m_aSchedule[5, 6] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[5, 6] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 2)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[6, 6].ToString() != "")
                                    m_aSchedule[6, 6] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[6, 6] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[7, 6].ToString() != "")
                                    m_aSchedule[7, 6] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[7, 6] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[8, 6].ToString() != "")
                                    m_aSchedule[8, 6] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[8, 6] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[9, 6].ToString() != "")
                                    m_aSchedule[9, 6] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[9, 6] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[10, 6].ToString() != "")
                                    m_aSchedule[10, 6] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[10, 6] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 3)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[11, 6].ToString() != "")
                                    m_aSchedule[11, 6] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[11, 6] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[12, 6].ToString() != "")
                                    m_aSchedule[12, 6] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[12, 6] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[13, 6].ToString() != "")
                                    m_aSchedule[13, 6] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[13, 6] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[14, 6].ToString() != "")
                                    m_aSchedule[14, 6] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[14, 6] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[15, 6].ToString() != "")
                                    m_aSchedule[15, 6] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[15, 6] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                    }
                    if (int.Parse(m_tblWeek2.Rows[i]["Training_WeekDayKey"].ToString()) == 7)
                    {
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 1)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[1, 7].ToString() != "")
                                    m_aSchedule[1, 7] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[1, 7] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[2, 7].ToString() != "")
                                    m_aSchedule[2, 7] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[2, 7] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[3, 7].ToString() != "")
                                    m_aSchedule[3, 7] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[3, 7] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[4, 7].ToString() != "")
                                    m_aSchedule[4, 7] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[4, 7] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[5, 7].ToString() != "")
                                    m_aSchedule[5, 7] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[5, 7] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 2)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[6, 7].ToString() != "")
                                    m_aSchedule[6, 7] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[6, 7] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[7, 7].ToString() != "")
                                    m_aSchedule[7, 7] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[7, 7] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[8, 7].ToString() != "")
                                    m_aSchedule[8, 7] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[8, 7] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[9, 7].ToString() != "")
                                    m_aSchedule[9, 7] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[9, 7] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[10, 7].ToString() != "")
                                    m_aSchedule[10, 7] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[10, 7] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 3)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[11, 7].ToString() != "")
                                    m_aSchedule[11, 7] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[11, 7] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[12, 7].ToString() != "")
                                    m_aSchedule[12, 7] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[12, 7] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[13, 7].ToString() != "")
                                    m_aSchedule[13, 7] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[13, 7] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[14, 7].ToString() != "")
                                    m_aSchedule[14, 7] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[14, 7] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[15, 7].ToString() != "")
                                    m_aSchedule[15, 7] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[15, 7] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                    }
                    if (int.Parse(m_tblWeek2.Rows[i]["Training_WeekDayKey"].ToString()) == 1)
                    {
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 1)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[1, 8].ToString() != "")
                                    m_aSchedule[1, 8] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[1, 8] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[2, 8].ToString() != "")
                                    m_aSchedule[2, 8] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[2, 8] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[3, 8].ToString() != "")
                                    m_aSchedule[3, 8] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[3, 8] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[4, 8].ToString() != "")
                                    m_aSchedule[4, 8] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[4, 8] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[5, 8].ToString() != "")
                                    m_aSchedule[5, 8] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[5, 8] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 2)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[6, 8].ToString() != "")
                                    m_aSchedule[6, 8] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[6, 8] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[7, 8].ToString() != "")
                                    m_aSchedule[7, 8] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[7, 8] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[8, 8].ToString() != "")
                                    m_aSchedule[8, 8] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[8, 8] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[9, 8].ToString() != "")
                                    m_aSchedule[9, 8] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[9, 8] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[10, 8].ToString() != "")
                                    m_aSchedule[10, 8] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[10, 8] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                        if (int.Parse(m_tblWeek2.Rows[i]["Training_SessionKey"].ToString()) == 3)
                        {
                            if (m_tblWeek2.Rows[i]["ClassID"].ToString() != "")
                                if (m_aSchedule[11, 8].ToString() != "")
                                    m_aSchedule[11, 8] += " - " + m_tblWeek2.Rows[i]["ClassID"].ToString();
                                else
                                    m_aSchedule[11, 8] = m_tblWeek2.Rows[i]["ClassID"].ToString();
                            if (m_tblWeek2.Rows[i]["SubjectName"].ToString() != "")
                                if (m_aSchedule[12, 8].ToString() != "")
                                    m_aSchedule[12, 8] += " - " + m_tblWeek2.Rows[i]["SubjectName"].ToString();
                                else
                                    m_aSchedule[12, 8] = m_tblWeek2.Rows[i]["SubjectName"].ToString();
                            if (m_tblWeek2.Rows[i]["Credit"].ToString() != "")
                                if (m_aSchedule[13, 8].ToString() != "")
                                    m_aSchedule[13, 8] += " - " + m_tblWeek2.Rows[i]["Credit"].ToString();
                                else
                                    m_aSchedule[13, 8] = m_tblWeek2.Rows[i]["Credit"].ToString();
                            if (m_tblWeek2.Rows[i]["PersonName"].ToString() != "")
                                if (m_aSchedule[14, 8].ToString() != "")
                                    m_aSchedule[14, 8] += " - " + m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                                else
                                    m_aSchedule[14, 8] = m_tblWeek2.Rows[i]["PersonLastName"].ToString() + " " + m_tblWeek2.Rows[i]["PersonName"].ToString();
                            if (m_tblWeek2.Rows[i]["RoomID"].ToString() != "")
                                if (m_aSchedule[15, 8].ToString() != "")
                                    m_aSchedule[15, 8] += " - " + m_tblWeek2.Rows[i]["RoomID"].ToString();
                                else
                                    m_aSchedule[15, 8] = m_tblWeek2.Rows[i]["RoomID"].ToString();
                            continue;
                        }
                    }
                }
            }
        }
    }
}
